﻿using Health.Code;
using Health.Domain;
using Health.Infrastructure.Interface;
using Health.WebAPI.Read.Applicant.Command;
using MediatR;

namespace Health.WebAPI.Read.Applicant.CommandHandler
{
    /// <summary>
    /// 显示价目查询列表
    /// </summary>
    public class ShowPricelistCommandHandler : IRequestHandler<ShowPricelistCommand, APIRestl<List<Pricelist>>>
    {
        IBaseRepository<Pricelist> priceRep;

        public ShowPricelistCommandHandler(IBaseRepository<Pricelist> priceRep)
        {
            this.priceRep = priceRep;
        }

        public Task<APIRestl<List<Pricelist>>> Handle(ShowPricelistCommand request, CancellationToken cancellationToken)
        {
            APIRestl<List<Pricelist>> restl = new APIRestl<List<Pricelist>>();
            restl.code = APIEnum.显示成功;
            restl.mes = APIEnum.显示成功.ToString();

            var list = priceRep.GetAll();

            restl.data = list.ToList();

            return Task.FromResult(restl);
        }
    }
}
